import type { StoryItem } from "../apis/story/type"

export const filterWorkDataByStatus = (items: StoryItem[], status: string | string[]) => {
  return items.filter(item => {

    if (Array.isArray(status)) {
      return status.includes(item.status)
    }

    if (status === 'in-progress') {
      if (item.status === 'in-progress') {
        if (item.children) {
          item.children = item.children.filter(child => child.status === 'in-progress')
        }
        return true
      }
      return false
    }

    if (status === 'new') {
      return true
    }
    return item.status === status
  })
}